package com.baizhi.wd.action;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.baizhi.wd.entity.Person;
import com.baizhi.wd.service.TelbookService;
import com.baizhi.wd.service.TelbookServiceImpl;

public class QueryPersonDetailAction extends HttpServlet {
	public void service(HttpServletRequest request,HttpServletResponse response) throws IOException{
		try{
			//1获取表单信息
			String idd = request.getParameter("id");
			int id = Integer.parseInt(idd);
			//2调用业务类方法
			TelbookService ts = new TelbookServiceImpl();
			Person onePerson = ts.getOnePerson(id);
			//
			request.setCharacterEncoding("utf-8");
			request.setAttribute("Person", onePerson);
			//3.根据查询结果跳转
			RequestDispatcher rd = request.getRequestDispatcher("/per/queryPersonDetailView");
			rd.forward(request, response);
			
		}catch(Exception e){
			e.printStackTrace();
			response.sendRedirect("/telbook_2/catchError.html");	
		}
	}
}
